import React, {Component} from 'react';

//类式组件
class ClassCount extends Component{

    state = {
        count: 0
    }

    add = () => {
        this.setState((state) => ({count: state.count + 1}))
    }

    render() {
        return (
            <div>
                <h2>当前点赞数={this.state.count}</h2>
                <button onClick={this.add}>点赞</button>
            </div>
        );
    }
}

export default ClassCount
